package practice;

import java.util.Scanner;

public class _整数反转_ {
    public static void main(String[] args) {
        _整数反转_ c = new _整数反转_();
        Solution s = c.getSolution();
        Scanner sc = new Scanner(System.in);
        int input = sc.nextInt();
        System.out.println(s.reverse(input));
    }

    public Solution getSolution() {
        return new Solution();
    }

    class Solution {
        public int reverse(int num) {
            long res = 0;
            if (num/10 == 0) return num;

            while ( num != 0) {
                res = res*10 + num%10;
                num /= 10;
                if ((int)res != res) return 0;
            }
            return (int)res;
        }
    }

}
